/*
*** (C) 2008-2009 UCMai.com ***

Subj: 用户管理-修改密码
Auth: lingq,yahao
Date: 2008-07-31
*/

c.pgsubject = '用户';

var UserPass = function(){
	//修改密码表单项
	this.formPassItems=[
		{
			inputType:'password',
			fieldLabel: '旧密码',
			name: 'LoginPass',
			id:'se_o_loginpass',
			anchor:'85%',
			allowBlank:false
		},
		{
			inputType:'password',
			fieldLabel: '新密码',
			name: 'NewLoginPass',
			id:'se_o_newloginpass',
			anchor:'85%',
			allowBlank:false
		},
		{
			inputType:'password',
			fieldLabel: '确认密码',
			name: 'NewLoginPass2',
			id:'se_o_newloginpass2',
			anchor:'85%',
			allowBlank:false
		},
		{xtype:'hidden',name: 'a',id:'se_o_cmdid'},
		{xtype:'hidden',name: 'li',id:'se_o_li'},
		{xtype:'hidden',name: 'ln',id:'se_o_ln'}
	];

	//修改密码
	this.showPassWin=function(){
		zyt.Permit();
		this.form = new Ext.FormPanel({
				labelAlign:'left',
				bodyStyle:'padding:5px',
				frame:true,
				labelWidth:60,
				items:[
					{
						layout:'form',
						defaultType:'textfield',
						border:false,
						labelSeparator:'：',
						items:this.formPassItems
				}]
		});
		this.form.getForm().reset();
		this.window = new Ext.Window({
			xtype:'window',
			title:'修改密码',
			buttonAlign : 'right',
			closable:true,
			resizable: false,
			layout:'fit',
			modal: 'true',
			width:320,
			height:180,
			closeAction:'hide',
			plain: true,
			items:[this.form],
			keys: {
				key: Ext.EventObject.ENTER,
				fn: savepass.createDelegate(this)
			},
			buttons: [{
				id: 'btnSave',
				text: c.bsave,
				handler: savepass.createDelegate(this),
				disabled: false
			},{
				text: c.bcancel,
				handler: function(){
					this.window.hide();
				}.createDelegate(this)
			}]
		});
		this.window.on('hide',function(){
			this.form.destroy();
		}.createDelegate(this));
		this.window.show();
		this.form.findById('se_o_loginpass').focus(false,true);
	};

	var savepass = function(){
		if (!this.form.getForm().isValid()){
			return;
		}
		var pass = this.form.findById('se_o_newloginpass').getValue();
		var pass2 = this.form.findById('se_o_newloginpass2').getValue();
		if(pass!=pass2){
			alertTip('两次输入密码不一致，请确认后重新输入');
			return false;
		}
		this.form.findById('se_o_cmdid').setValue(9);
		showLoading(c.g(c.e.save),c.loading);
		zyt.ajax(_C_User_PassModify, this.form.getForm().getValues(), function(){
			hideLoading();
			this.window.hide();
			var act = c.modify;
			Ext.HandleTip.msg(c.opres,'密码'+ act +c.ok);
		}.createDelegate(this));
	}

	this.showPassWin();
};